package edu.ecust.design.springext;

import java.util.Set;

import org.apache.commons.lang.StringUtils;
import org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping;

public class DesignAnnotationHandlerMapping extends
		DefaultAnnotationHandlerMapping {
	private boolean addDirSuffix;
	private String fileSuffixs;
	private String[] fileSuffixArray;

	public DesignAnnotationHandlerMapping() {
		this.addDirSuffix = true;

		this.fileSuffixs = "*";
	}

	protected void addUrlsForPath(Set<String> urls, String path) {
		String[] arr$;
		int i$;
		urls.add(path);
		if ((path.indexOf(46) == -1) && (!(path.endsWith("/")))) {
			if (this.addDirSuffix)
				urls.add(path + "/");
			if (this.fileSuffixArray != null) {
				arr$ = this.fileSuffixArray;
				int len$ = arr$.length;
				for (i$ = 0; i$ < len$; ++i$) {
					String suffix = arr$[i$];
					if (!(StringUtils.isEmpty(suffix)))
						urls.add(path + "." + suffix);
				}
			}
		}
	}

	public void setAddDirSuffix(boolean addDirSuffix) {
		this.addDirSuffix = addDirSuffix;
	}

	public boolean isAddDirSuffix() {
		return this.addDirSuffix;
	}

	public void setFileSuffixs(String fileSuffixs) {
		this.fileSuffixs = fileSuffixs;
		if (StringUtils.isEmpty(fileSuffixs))
			this.fileSuffixArray = new String[0];
		else
			this.fileSuffixArray = fileSuffixs.split("[,\\s]+");
	}

	public String getFileSuffixs() {
		return this.fileSuffixs;
	}
}
